<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
	<head>
		<th:block th:include="include :: header('新增数据集页面')" />
		<link th:href="@{/css/common.css}" rel="stylesheet"/>
		<link th:href="@{/css/choose_data_map.css}" rel="stylesheet"/>
	</head>
	<body class="gray-bg">
		<div class="wrapper wrapper-content add-datamap">
			<div class="ibox-content">
				<form class="form-horizontal" id="form-parameter-add">
					<input type="hidden" name="objectEnName" id="objectEnName" th:value="${objectEnName}">
					<input type="hidden" name="objectEnName" id="objectName" th:value="${objectName}">
					<input type="hidden" name="interfaceId" id="interfaceId" th:value="${interfaceId}">
					<input type="hidden" name="isInParam" id="isInParam" th:value="${isInParam}">
					<input type="hidden" name="type" id="type" th:value="${type}">
					<div class="form-group">
						<div class="pull-right" style="width: 100%;">
							<input id="zhName" name="zhName" type="text" class="form-control" placeholder="输入结果集名称" required>
						</div>
					</div>
					<div class="form-group">
						<div class="pull-right" style="width: 100%;">
							<input id="enName" name="enName" type="text" class="form-control" placeholder="输入结果集英文名称" required>
						</div>
					</div>
					<div class="form-group">
						<div class="pull-right" style="width: 100%;">
							<input id="objectDtoName" name="objectDtoName" type="text" class="form-control" placeholder="输入对象DTO名称" required>
						</div>
					</div>
				</form>
			</div>
		</div>
	</body>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "parameters/parameter"
		$("#form-parameter-add").validate({
			focusCleanup: true
		});

		var objectName = $("#objectName").val();
		var objectEnName = $("#objectEnName").val();
		if (objectName || objectEnName) {
			$("#zhName").val(objectName);
			$("#enName").val(objectEnName + "List");
			$("#objectDtoName").val(objectEnName);
		}

		$("#enName").change(function () {
			var value = $(this).val();
			if (value && value.length > 4) {
				var l = value.substring(value.length-4);
				if (l == 'List') {
					$("#objectDtoName").val(value.substring(0, value.length-4))
				} else {
					$("#objectDtoName").val(value);
				}
			} else {
				$("#objectDtoName").val(value);
			}
		});

		function submitHandler() {
			var flag = false;
			if ($.validate.form()) {
				var config = {
					url: prefix + "/add",
					type: "post",
					async: false,
					dataType: "json",
					data: $('#form-parameter-add').serialize(),
					beforeSend: function () {
						$.modal.loading("正在处理中，请稍后...");
						$.modal.disable();
					},
					success: function(result) {
						$.modal.closeLoading();
						if (result.code == web_status.SUCCESS) {
							//$("#searchDiv" , window.parent.document).click();
							//window.parent.loadParams();
							//$.modal.close();
							//$.operate.successCallback(result);
							flag = true;
						} else {
							$.modal.alertWarning(result.msg);
						}
						$(".layui-layer-btn0", window.parent.document).removeClass('layer-disabled');
						$(".layui-layer-btn1", window.parent.document).removeClass('layer-disabled');
						$(".layui-layer-btn2", window.parent.document).removeClass('layer-disabled');
					}
				};
				$.ajax(config)
			}
			return flag;
		}
	</script>
</html>
